package com.syqc.monitor.ui.carinfo

import androidx.lifecycle.MutableLiveData
import autodispose2.autoDispose
import com.syqc.comlib.auto.AutoDisposeViewModel
import com.syqc.net.ServiceHelper

/**
 *@author  hfjs
 *@time   2024/8/22 9:46
 *@desc
 */
class CarTmnVM : AutoDisposeViewModel() {
    var mainTmn: MutableList<String>? = null
    var videoTmn: MutableList<String>? = null
    var adasTmn: MutableList<String>? = null
    val loadLive = MutableLiveData<Boolean>()

    fun getCarInfo(carId: String) {
        toastLoading(true)
        ServiceHelper.getRepository().getCarInfo(carId).autoDispose(this).subscribe({
            toastLoading(false)
            mainTmn=null
            videoTmn=null
            adasTmn=null
            if (it.mainTmn != null) {
                mainTmn = it.mainTmn.tmnPicMap?.values?.toMutableList()
            }
            if (it.videoTmn != null) {
                videoTmn = it.videoTmn.videoTmnPicMap?.values?.toMutableList()
            }
            if (it.adasTmn != null) {
                adasTmn = it.adasTmn.adasTmnPicMap?.values?.toMutableList()
            }
            loadLive.postValue(true)
        }, error)
    }
}